package com.codinghero.zqlb.spider.handler;

import java.util.List;

import com.codinghero.sql.MySQLOper;
import com.codinghero.zqlb.Constant;
import com.codinghero.zqlb.match.SoccerMatch;

@Deprecated
public class DeleteDupMatchHandler implements MatchHandler {

	public <T extends SoccerMatch> void handle(List<T> list) {
		MySQLOper dbOper = new MySQLOper(Constant.JDBC_URL, Constant.USER_ID,
				Constant.PASSWORD);
		try {
			dbOper.connect();
			dbOper.startTransaction();
			dbOper.addBatch("DELETE t FROM zqlb_soccer_match_temp t, zqlb_soccer_match m "
					+ " WHERE t.startDate = m.startDate AND t.typeId=m.typeId "
					+ " AND t.team1Id = m.team1Id AND t.team2Id=m.team2Id");
			dbOper.addBatch("DELETE t FROM zqlb_soccer_match_temp t, zqlb_soccer_match m "
					+ " WHERE t.startDate = m.startDate AND t.typeName=m.typeName "
					+ " AND t.team1Name = m.team1Name AND t.team2Name=m.team2Name");
			dbOper.executeBatch();
			dbOper.commit();
		} catch (Exception e) {
			dbOper.rollback();
			e.printStackTrace();
		} finally {
			dbOper.close();
		}
	}

}
